home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
VIVIDUS
/
QD3D.SIT
/
qd3d
/
Cqd3dPort.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-04
|
7KB
|
225 lines
#pragma once
#include <vect.h>
/* ======================================================================
This header file is Copyright 1991 by Vividus Consulting.
This is not public domain source code. You may not copy and
paste from this source code. Read your Vividus Licensing
agreement for details and other restrictions.
This header file is for anything that uses the qd3d Vividus
Source Code Library.
====================================================================== */
// Projection types served by this class.
enum {
kqd3dPortPerspective = 0,
kqd3dPortParallel
};
class Cqd3dPort : indirect {
public:
/* Public read only instance variables: */
vector Ua2f; /* Unit vector pointing from at to eye. */
int type; /* Projection type. */
vector tmat[3], /* Eye coordinate transformation matrix. */
tmatinv[3]; /* Inverse transformation matrix. */
/* PRIVATE instance variables: */
/* Use these at your own risk! */
vector f, /* Eye position. */
a, /* Center of attention. */
u; /* "Up" vector of eye. */
double v; /* View angle. (perspective proj.) */
double al, ar, at, ab; /* EC view rectangle. (parallel proj.) */
GWorldPtr gw; /* The GWorld to draw into. */
GrafPtr gp; /* The GrafPort to draw to. */
/* Both are not concurrently used. */
Rect vport; /* The portion of the QuickDraw */
/* environment to draw to. */
unsigned int *zbuff, /* The z-buffer. */
*zbufflast,
zbuffwidth;
Boolean onlyqd, /* Only use quickdraw operations. Ie. */
/* No gouraud shaded polygons or linear */
/* blended color lines. */
cullbacks, /* True = hide, False = show. */
usezbuff, /* If applicable, attempt to use */
/* zbuffer. */
usedepthque, /* Depth que to the background */
/* color. */
wireframe; /* Map all fill calls to frame calls. */
int lastError; /* The last recorded qd3d error. Error */
/* codes listed below. */
Fixed fFract; /* Depth queue: fraction of depth color */
/* at far plane. */
FixedVector dColor; /* Depth queue: background color to blend */
/* to. */
double zMin, zMax; /* Near and far planes (EC.z). */
int pwidth, /* Projection constants and coefficients. */
plength,
pmin;
double pb, pd, pe, pf;
int pa, pc;
vector position, /* These are for MoveTo and LineTo. */
color;
/* Public methods: */
void Init(void);
void SetQDEnviron(void);
void SetQDRect(Rect *r);
void Set3dPort(void);
void Dispose(void);
void Erase(void);
void DrawOrigin(double size);
void SetView(
vector *f,
vector *a,
vector *u);
void GetView(
vector *f,
vector *a,
vector *u);
void SetPolarView(
vector *a,
double rho,
double theta,
double phi,
double twist);
void GetPolarView(
vector *a,
double *rho,
double *theta,
double *phi,
double *twist);
int GetProjectionType(void);
void SetPerspective(
double v,
double near,
double far);
void GetPerspective(
double *v,
double *near,
double *far);
void SetParallel(
vector *upperLeft,
vector *lowerRight,
double near,
double far);
void GetParallel(
vector *upperLeft,
vector *lowerRight,
double *near,
double *far);
int Qd3dError(void);
Boolean GetOnlyQD(void);
void SetOnlyQD(Boolean onOff);
Boolean GetCullBacks(void);
void SetCullBacks(Boolean onOff);
Boolean GetUseZBuff(void);
void SetUseZBuff(Boolean onOff);
Boolean GetDepthQue(void);
void SetDepthQue(
Boolean onOff,
vector *fadeColor,
double furthestFraction);
Boolean GetWireframe(void);
void SetWireframe(Boolean onOff);
/* Private methods: */
/* Use these at your own peril. */
protected:
void BuildTMat(void);
void BuildProj(void);
};
/* Public functions" */
Cqd3dPort * Get3dPort(void);
int Qd3dError(void);
/* Presently defined error codes: */
/* #define noErr noErr */
#define noZBuffMem 1 /* Z-Buffer memory was unable to be allocated. */
#define moveOutVV 2 /* MoveTo outside of present view volume. */
/* ====================================================================== */
/* Public 3d primitives: */
#define PolyMaxN 10 /* The maximum number of vertices in a polygon. */
void Transform(int n, vector x[], vector xe[]);
void Project(int n, vector xe[], vector xp[]);
void TransformProject(int n, vector x[], vector xp[]);
void MoveTo3d(vector *x);
void LineTo3d(vector *x);
void Poly3dMark(int n, vector x[], void (*markf)(vector *pos));
void Poly3dLine(int n, vector x[]);
void Poly3dFrame(int n, vector x[]);
void Poly3dFrameErase(int n, vector x[]);
void Poly3dFill(int n, vector x[]);
void Poly3dErase(int n, vector x[]);
void PolyC3dMark(int n, vector x[], void (*markf)(vector *pos), vector c[]);
void PolyC3dLine(int n, vector x[], vector c[]);
void PolyC3dFrame(int n, vector x[], vector c[]);
void PolyC3dFill(int n, vector x[], vector c[]);
/* ====================================================================== */
/* Public default marking functions: */
#define CNTRLWDTH 2 /* Half the width of the control rep. */
#define SLTNWDTH 4 /* Half the width of the selected control rep */
void MarkPoint(vector *pos);
void MarkSelectedPoint(vector *pos);
void MarkCtrlPoint(vector *pos);
/* ====================================================================== */
/* Public color primitives: */
void Color2RGB(vector *c, RGBColor *rgb);
void RGB2Color(RGBColor *rgb, vector *c);
void vForeColor(vector *c);
/* ====================================================================== */
/* Private 3d primitives: */
Boolean Line3dClip(vector *p1, vector *p2, vector *cp1, vector *cp2);
Boolean LineC3dClip(
vector *p1, vector *p2, vector *cp1, vector *cp2,
vector *inc1, vector *inc2, vector *outc1, vector *outc2);
void Clip3d(int *n, vector inndc[], vector outndc[]);
void ClipC3d(int *n, vector inndc[], vector outndc[], vector inc[], vector outc[]);
void TranClipProjf(int *n, vector in[], FixedVector outdc[]);
void TranClipProjCf(int *n, vector in[], FixedVector outdc[], vector inc[], vector outc[]);
void Projectf(int n, vector xe[], FixedVector xp[]);
void TransformProjectf(int n, vector x[], FixedVector xt[]);
void ndc2fdc(int n, vector *v, FixedVector *fv);
/* ====================================================================== */
/* Private color primitives: */
void Color2RGB(vector *c, RGBColor *rgb);
void RGB2Color(RGBColor *rgb, vector *c);
void GetFColor(vector *c, FixedVector *fc);
void DepthColor(FixedVector *inc, Fixed z, FixedVector *oc);
void cv2rgb(FixedVector *f, RGBColor *rgb);
void rgb2cv(RGBColor *rgb, FixedVector *f);